import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Test2 {
    public static void main(String[] args) {
        try (BufferedReader br=new BufferedReader(new FileReader("D:\\文档\\重要文件\\csb.txt"));
             BufferedWriter bw=new BufferedWriter(new FileWriter("D:\\文档\\重要文件\\change.txt"))
        ){
            ArrayList<String>list=new ArrayList<>();
            String s;
            while((s=br.readLine())!=null){
                list.add(s);
            }
            Collections.sort(list, new Comparator<String>() {
                @Override
                public int compare(String o1, String o2) {
                    return o1.charAt(0)-o2.charAt(0);
                }
            });
            for (String t:list){
                bw.write(t);
                bw.newLine();
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
